<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>登录 - 钢域云贸</title>
    <link rel="icon" href="/uploads/logo.png" type="image/x-icon"/>
    <link rel="shortcut icon" href="/uploads/logo.png" type="image/x-icon"/>
    <link rel="stylesheet" href="/css/bootstrap.min.css" type="text/css" media="all"/>
    <link rel="stylesheet" type="text/css" href="/css/public.css"/>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css">
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" th:href="@{/css/amazeui.min.css}"/>
    <link rel="stylesheet" th:href="@{/css/login.css}"/>
    <style>
        /* 登录框居中 */
        body {
            display: flex;
            justify-content: center; /* 水平居中 */
            align-items: center; /* 垂直居中 */
            height: 100vh; /* 占满整个视口高度 */
            margin: 0;
            background-image: url('/uploads/background.jpg'); /* 设置背景图片 */
            background-size: cover;
            background-position: center;
            background-repeat: no-repeat;
            background-attachment: fixed; /* 背景固定 */
        }

        .form-signin {
            width: 100%;
            max-width: 400px;
            padding: 2rem;
            background-color: #fff; /* 背景白色 */
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1); /* 添加阴影 */
            border-radius: 8px; /* 圆角 */
        }

        /* 调整输入框和按钮样式 */
        .am-input-group {
            margin-bottom: 1rem;
            position: relative;
            width: 100%; /* 确保输入框组占满父容器 */
        }

        .am-input-group-label {
            position: absolute;
            right: 0;
            top: 0;
            height: 45px;
            width: 40px;
            padding: 0.5rem;
            background-color: #f5f5f5;
            border: 1px solid #ccc;
            border-right: none;
            border-radius: 0 5px 5px 0;
            display: flex;
            align-items: center;
            justify-content: center;
        }

        .form-control {
            width: 100%; /* 占满父容器 */
            height: 40px;
            padding-left: 2.5rem; /* 留出图标空间 */
            border-radius: 0 5px 5px 0;
            box-sizing: border-box; /* 确保padding不影响宽度 */
        }

        /* 登录和注册按钮样式 */
        .am-btn {
            width: 100%; /* 占满父容器 */
            height: 40px; /* 与输入框高度一致 */
            padding: 0; /* 移除默认padding，确保高度精确 */
            font-size: 1.1rem;
            line-height: 40px; /* 垂直居中文字 */
            box-sizing: border-box; /* 确保高度精确 */
            border-radius: 5px; /* 确保圆角矩形 */
        }

        /* 注册按钮样式 */
        .register-btn {
            margin-top: 1rem;
            background-color: #28a745; /* 绿色背景，区分登录按钮 */
            color: white;
        }

        .register-btn:hover {
            background-color: #218838;
        }

        /* 底部信息样式 */
        .footer-container {
            margin-top: 1.5rem;
            text-align: center;
        }

        .language-switcher {
            margin-top: 0.5rem;
        }
    </style>
</head>
<body>
<form class="form-signin" th:action="@{/login}" method="post">
    <h1 class="h3 mb-3 font-weight-normal" style="text-align: center" th:text="#{login.tip}">欢迎登录钢域云贸</h1>

    <!-- 错误信息 -->
    <div th:if="${param.error}" class="alert alert-danger" th:text="#{login.error}">用户名或密码错误!</div>
    <div th:if="${param.logout}" class="mb-4 p-4 bg-green-100 text-green-700 rounded-lg">
        您已成功登出
    </div>

    <!-- 隐藏的URL参数 -->
    <input type="hidden" name="url" th:value="${url}">

    <!-- 用户名输入 -->
    <div class="am-input-group am-radius am-animation-slide-left">
        <input type="text" class="form-control" th:placeholder="#{login.username}" name="username" required autofocus>
        <span class="am-input-group-label log-icon am-radius">
            <i class="am-icon-user am-icon-sm am-icon-fw"></i>
        </span>
    </div>

    <!-- 密码输入 -->
    <div class="am-input-group am-radius am-animation-slide-left log-animation-delay">
        <input type="password" class="form-control" th:placeholder="#{login.password}" name="password" required>
        <span class="am-input-group-label log-icon am-radius">
            <i class="am-icon-lock am-icon-sm am-icon-fw"></i>
        </span>
    </div>

    <!-- 记住我选项 -->
    <div class="checkbox mb-3">
        <label style="display: flex; align-items: center; gap: 5px;">
            <input type="checkbox" name="remember-me" value="true"
                   th:checked="${rememberMeCheck}" style="margin: 0;">
            <span>[[#{login.remember}]]</span>
        </label>
    </div>

    <!-- 登录按钮 -->
    <button class="am-btn am-btn-primary am-btn-block am-btn-lg am-radius am-animation-slide-bottom log-animation-delay" type="submit" th:text="#{login.button}">登录</button>

    <!-- 注册按钮 -->
    <a th:href="@{/register}" class="am-btn am-btn-block am-btn-lg am-radius register-btn">注册</a>

<!--     底部信息 -->
        <div class="footer-container">
            <p class="mt-5 mb-3 text-muted">©<span th:text="${currentYear}">2025</span>-<span th:text="${currentYear}+1">2026</span></p>
            <div class="language-switcher">
                <a class="btn btn-sm" th:href="@{/login(l='zh_CN')}">中文</a>
                <a class="btn btn-sm" th:href="@{/login(l='en_US')}">English</a>
            </div>
        </div>
</form>

<script src="/js/jquery-latest.min.js"></script>
<script src="/js/popper.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
<script src="/js/jquery.min.js"></script>
<script src="/js/amazeui.min.js"></script>
</body>
</html>